package com.etc.service;

import com.etc.dao.RoomInfoDao;
import com.etc.dao.UserInfoDao;
import com.etc.entity.RoomInfo;
import com.etc.entity.User;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoomInfoServiceImpl implements RoomInfoService{
    //调用持久层
    @Autowired
    RoomInfoDao dao;

    /**
     * 增加房间
     * 邓玲琪
     * @param
     * @return boolean int>0 为True  否则为False
     */
    @Override
    public int addRoomInfo(int roomNum,String rtId,String roomTel,int roomStatus,String roomFloog) {
        if(roomTel!="" &&roomFloog!="" &&roomNum!=0){
            return dao.addRoomInfo(roomNum,rtId,roomTel,roomStatus,roomFloog);
        }
        return 0;
    }
    /**
     * 根据房间编号删除房间
     * 邓玲琪
     * @param roomId 房间编号
     * @return boolean int>0 为True  否则为False
     */
    @Override
    public int delRoomInfo(String roomId) {
        return dao.delRoomInfo(roomId);
    }
    /**
     * 根据房间编号修改房间信息
     * 邓玲琪
     * @param roomInfo 房间对象
     * @return boolean int>0 为True  否则为False
     */
    @Override
    public int modifyRoomInfo(RoomInfo roomInfo) {
        return dao.modifyRoomInfo(roomInfo);
    }
    /**
     * 分页 查找所有房间信息
     * 邓玲琪
     *  @param pageNum
     * @param pageSize
     * @return pageInfo  （集合PageInfo<RoomInfo>）
     */
    @Override
    public PageInfo<RoomInfo> getqueryAllRoomInfo(int pageNum, int pageSize,int roomNum,int roomStatus, String rtName) {
        //1.开始分页
        PageHelper.startPage(pageNum, pageSize);
        //2.执行查询所有用户信息
        List<RoomInfo> list = dao.queryAllRoomInfos(roomNum,roomStatus,rtName);
        //3.通过pageInfo进行包装,PageInfo包含了非常丰富的分页属性
        PageInfo<RoomInfo> pageInfo = new PageInfo<RoomInfo>(list);
        return pageInfo;
    }
}
